#include <bits/stdc++.h>

#define in read()
#define fi first
#define se second
#define pb push_back
#define rep(i, x, y) for(int i = (x); i <= (y); i++) 
#define per(i, x, y) for(int i = (x); i >= (y); i--)

using namespace std;

using ll = long long;
using db = double;
using pii = pair < int , int >;
using vec = vector < int >;
using veg = vector < pii >;

int read() {
	int x = 0; bool f = 0; char ch = getchar(); while(!isdigit(ch)) f |= ch == '-', ch = getchar(); 
	while(isdigit(ch)) x = x * 10 + (ch ^ 48), ch = getchar(); return f ? -x : x;
}

const int N = 2010;

char p[N][N];
int n, m, s[N][N], ex[N][N], ey[N][N], Q;

int get(int t[N][N], int a, int b, int x, int y) {
	return t[x][y] - t[a - 1][y] - t[x][b - 1] + t[a - 1][b - 1];
}

int main() {
#ifndef ONLINE_JUDGE
	freopen("1.in", "r", stdin);
#endif
	n = in, m = in, Q = in;
	rep(i, 1, n) scanf("%s", p[i] + 1);
	rep(i, 1, n) rep(j, 1, m) s[i][j] = s[i - 1][j] + s[i][j - 1] - s[i - 1][j - 1] + (p[i][j] == '1');
	rep(i, 1, n) rep(j, 1, m) ex[i][j] = ex[i - 1][j] + ex[i][j - 1] - ex[i - 1][j - 1] + (p[i][j] == '1' && p[i - 1][j] == '1');
	rep(i, 1, n) rep(j, 1, m) ey[i][j] = ey[i - 1][j] + ey[i][j - 1] - ey[i - 1][j - 1] + (p[i][j] == '1' && p[i][j - 1] == '1');
	rep(i, 1, Q) { 
		int a = in, b = in, x = in, y = in;
		int ans = get(s, a, b, x, y) - get(ex, a + 1, b, x, y) - get(ey, a, b + 1, x, y);
		printf("%d\n", ans);
	}
	return 0;
}
